home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group98a.txt
/
000001_icon-group-sender _Tue Jan 13 09:32:16 1998.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
3KB
Return-Path: <icon-group-sender>
Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
by baskerville.CS.Arizona.EDU (8.8.7/8.8.7) with SMTP id JAA26735
for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Tue, 13 Jan 1998 09:32:15 -0700 (MST)
Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
id AA20742; Tue, 13 Jan 1998 09:32:15 -0700
X-Sender: nevin@pop.interaccess.com (Unverified)
Message-Id: <v04003901b0e0c25d0101@[204.148.87.66]>
In-Reply-To: <swampler-9800081533.AA0009292@orpheus.gemini.edu>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Date: Tue, 13 Jan 1998 01:08:52 -0600
To: icon-group@optima.CS.Arizona.EDU
From: "Nevin :-] Liber" <nevin@pendragon-software.com>
Subject: Re: Stripping blank and comment lines
Cc: swampler@noao.edu (Steve Wampler)
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
Content-Length: 1609
At 9:33 AM -0600 1/8/98, Steve Wampler wrote:
> Write a program that strips out blank lines and comment lines (lines
> that only contain a comment) from Icon programs. The program should
> accept 0 or more file names as arguments and copy the files to standard
> output with all blank and comment lines removed. If no arguments are
> given, then the program should read from standard input.
I'll start the ball rolling. Here is my solution; in the spirit of Steve's
message to try and get some discussion going, I'll leave it up to others to
comment upon the elegance/inelegance of it and to make suggestions on other
ways to implement it. Enjoy!
Nevin :-)
procedure main(LArguments)
local fInput
local sLine
every fInput := InputFiles(LArguments) do {
while sLine := read(fInput) do {
write(ValidSourceLine(sLine))
}
}
end
procedure InputFiles(LFilenames)
local sFilename
local fFile
if 0 = *LFilenames then {
return &input
}
every sFilename := !LFilenames do {
if not (fFile := open(sFilename)) then {
write(&errout, "Cannot open ", image(sFilename), "
for reading.")
next
}
suspend fFile
close(fFile)
}
end
procedure ValidSourceLine(sLine)
sLine ? {
tab(many('\t '))
if ="#" | not move(1) then {
fail
}
}
return sLine
end
--
Nevin ":-)" Liber <mailto:nevin@pendragon-software.com> (847) 816-9926
Senior Software Engineer, Pendragon Software <http://www.webfayre.com/>
Pendragon Software Corporation
1580 South Milwaukee Avenue, Suite 515
Libertyville, IL 60048-3776
voice: (847) 816-9660
fax: (847) 816-9710